package ddbs;

import java.io.IOException;


public class Ddbs {
    Configuration conf = null;
    PeerMgr mgr = null;
    Sched sch = null;
    Gui gui = null;
    public Ddbs(String filename) throws IOException{
         conf = new Configuration(filename);
         int http_port = Integer.parseInt(conf.getConf("HTTP_PORT"));
         mgr = new PeerMgr(conf);
         sch = new Sched(mgr);
         mgr.sch = sch;
         gui = new Gui(conf, sch, http_port);
         DatabaseQuery.init(conf);
         WorkFactory.registerCreater(Work.STATUS, new SimpleWorkCreater(mgr));
         WorkFactory.registerCreater(BinWork.STATUS, new BinWorkCreater(mgr));
     }
     public void start(){
         mgr.start();
         gui.start();
     }
    
    /**
     * @param args
     */
    public static void main(String[] args) {
        try {
            Ddbs ddbs = new Ddbs("ddbs.ini");
            ddbs.start();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
